package net.tp.algo.hash;

import java.util.function.Function;

/**
 * User: Trung
 * Date: 4/30/13
 * Time: 7:17 AM
 */
public class MinHash {

    public static <T> int hash(Iterable<T> elements, Function<T, Integer> hashFunction) {
        int minHash = Integer.MAX_VALUE;
        for (T element : elements) {
            int hash = hashFunction.apply(element);
            if (hash < minHash) {
                minHash = hash;
            }
        }

        return minHash;
    }


}
